package com.wesley.test.service;

import com.wesley.test.dao.UserDao;
import com.wesley.test.entity.User;
import com.wesley.test.form.UserForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    private UserDao userDao;

    public void saveUser(User user) throws Exception{
        userDao.save(user);
    }

    public List<User> getAllUser() {
        return userDao.findAll();
    }


    public User getByName(String name){
        return userDao.getByName(name);
    }


    public List<User> findUser(UserForm userForm){
        return userDao.findByNameAndSex(userForm.getName(), userForm.getSex());
    }


    public void deleteById(int id) {
		userDao.deleteByUid(id);
	}
    
    
}
